﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Net;
using System.Net.Http;
using System.Web.Http;
using ExpenseSystem.Core;
using ExpenseSystem.Core.Authority;
using ExpenseSystem.Core.SiteModules;
using ExpenseSystem.Fether;
using ExpenseSystem.Common;
using ExpenseSystem.Lor;
using ExpenseSystem.Model;
using ExpenseSystem.Common.BaseModel;

namespace ExpenseSystem.Controllers
{
    [RoutePrefix("api/Site")]
    public class SiteController : ApiController
    {
        SetInhibition setInhibition;
        GetInhibition getInhibition;
        SetInhibitionMaker inhibitionMaker = new StateInhibitionMaker();
        GetInhibitionMaker getInhibitionMaker = new GetInhibitionMaker();
        public SiteController()
        {
            setInhibition = inhibitionMaker.Make();
            getInhibition = getInhibitionMaker.Make();
        }
        [Route("List")]
        [HttpGet]
        public ResponseModel List()
        {
            return SystemControllerHelper.List(new SiteFetcher(), "", null, getInhibition);
            //登录的时候需要调取该信息，故这里不做权限鉴定
        }
        [Route("Get")]
        [HttpGet]
        public ResponseModel Get(long id)
        {
            return SystemControllerHelper.Get(new SiteFetcher(), "SYS_SITE_LIST", id, getInhibition);
        }
        [Route("Set")]
        [HttpPost]
        public ResponseModel SetSite(SiteModel data)
        {
            return SystemControllerHelper.Set(new SiteFetcher(), "SYS_SITE_SET", data, SiteManager.CreateInstance(),  setInhibition);
        }

        [Route("Remove")]
        [HttpPost]
        public ResponseModel RemoveSite(SiteModel data)
        {
            return SystemControllerHelper.Remove( "SYS_SITE_DEL", data, SiteManager.CreateInstance());
        }
    }
}
